import HomeView from "@/views/Home/index.vue"
import LoginView from "@/views/Login/index.vue"
import NotFound from "@/views/NotFound/index.vue"

import HomeDefaultView from "@/views/Home/Layout/index.vue"

import AdminView from "@/views/Home/Admin/index.vue"
import AdminListView from "@/views/Home/Admin/AdminList/index.vue"
import AdminAddView from "@/views/Home/Admin/AdminAdd/index.vue"

import ProductListView from "@/views/Home/Product/ProductList/index.vue"
import ProductManageView from "@/views/Home/Product/ProductManage/index.vue"

import BannerListView from "@/views/Home/Banner/BannerList/index.vue"
import BannerShowView from "@/views/Home/Banner/BannerShow/index.vue"





export default [
  // 一级视图  
  {
    path: '/',
    name: 'home',
    redirect: "/home",
    meta: {
      requireAuth: true, // 当前页面是否需要登录
      role: ["super", "admin", "user"], // 哪些用户可以访问当前页面 
    },
    component: HomeView,
    // 二级视图  => 渲染在 / 路由下的router-view的二级视图
    children: [{
      path: '/home',
      name: 'default',
      label: "首页",
      icon: "HomeFilled",
      meta: {
        requireAuth: true, // 当前页面是否需要登录
        role: ["super", "admin", "user"], // 哪些用户可以访问当前页面 
      },
      component: HomeDefaultView
    }, {
      path: "/admin",
      name: "admin",
      label: "人员管理",
      meta:{requireAuth:true, role:["super"]},
      icon: "User",
      redirect: "/admin/list",
      // component: AdminView,  (!!! 如果此处设置component => children中的内容就是三级视图,如果不设置children中的内容就是二级视图)

      // 三级视图
      children: [{
        path: '/admin/list',   // 在二级视图中展示
        name: 'admin-list',
        label: "人员列表",
        icon: "",
        meta:{requireAuth:true, role:["super"]},
        component: AdminListView,
      }, {
        path: '/admin/add',
        name: 'admin-add',
        label: "人员新增",
        icon: "",
        meta:{requireAuth:true, role:["super"]},
        component: AdminAddView
      }]
    }, {
      path: "/product",
      name: "product",
      redirect: "/product/list",
      label: "商品管理",
      icon: "Goods",
      meta:{requireAuth:true, role:["super","admin","user"]},
      children: [{
        path: "/product/list",
        name: "product-list",
        label: "商品列表",
        icon: "",
        meta:{requireAuth:true, role:["super","admin","user"]},
        component: ProductListView
      }, {
        path: "/product/manage",
        name: "product-manage",
        label: "推荐秒杀",
        icon: "",
        meta:{requireAuth:true, role:["super","admin"]},
        component: ProductManageView
      }]
    }, {
      path: "/banner",
      name: "banner",
      redirect: "/banner/list",
      label: "轮播管理",
      icon: "Wallet",
      meta:{requireAuth:true, role:["super","admin","user"]},
      children: [{
        path: "/banner/list",
        name: "banner-list",
        label: "轮播列表",
        icon: "",
        meta:{requireAuth:true, role:["super","admin"]},
        component: BannerListView
      }, {
        path: "/banner/show",
        name: "banner-show",
        label: "轮播展示",
        icon: "",
        meta:{requireAuth:true, role:["super","admin","user"]},
        component: BannerShowView
      }]
    }, {
      path: "/order",
      name: "order",
      redirect: "/order/list",
      label: "订单管理",
      icon: "Menu",
      meta:{requireAuth:true, role:["super","admin","user"]},
      children: [{
        path: "/order/list",
        name: "order-list",
        label: "订单列表",
        icon: "",
        meta:{requireAuth:true, role:["super","admin"]},
        component: BannerListView
      }, {
        path: "/order/manage",
        name: "order-manage",
        label: "订单管理",
        icon: "",
        meta:{requireAuth:true, role:["super","admin"]},
        component: BannerShowView
      }]
    }],
  },
  {
    path: '/login',
    name: 'login',
    meta:{requireAuth:false},
    component: LoginView
  },
  {
    path: '/404',
    name: 'not-found',
    meta:{requireAuth:false},
    component: NotFound
  },
  {
    path: "/:pathMatch(.*)*",
    redirect: "/404",
  }
]

